extends Node2D

enum POLL_TYPE_ENUM {
	DRAW,DISCARD
}

@export var pool_type:POLL_TYPE_ENUM

@onready var card_num = $MarginContainer/CardNumLabel

signal shuffle

var poll : CardPool
var n:int = 0
var shuffleing = false
func set_card_num(num):
	card_num.set_text(str(num))

func _ready():
	shuffle.connect(_on_shuffle)	

func _process(_delta):
	if(shuffleing):
		set_card_num(n)
	else:
		if poll != null:
			set_card_num(poll.get_card_count())

func _on_shuffle():
	shuffleing = true
	var tween = create_tween()
	if pool_type == POLL_TYPE_ENUM.DRAW:
		n = 0
		var temp = CardManager.discard_pool.get_card_count()
		tween.tween_property(self,"n",temp,0.5)
	else:
		n = CardManager.discard_pool.get_card_count()
		tween.tween_property(self,"n",0,0.5)
		CardManager.discard_poll_shuffle()
	tween.play()
	await tween.finished
	tween.kill()
	shuffleing = false



